import { createStore } from 'vuex'


export default createStore({
  /* state */
  state: {
    token: localStorage.getItem('token'),
    userdata: JSON.parse(localStorage.getItem('userdata') as string),
    userDataList: null,
    mergeData: {}
  } as {
    token: string,
    userdata: string,
    userDataList: any | null,
    mergeData: object
  },

  /* commit */
  mutations: {
    token(state, payload) {
      localStorage.setItem('token', payload.token)
    },
    userdata(state, payload) {
      localStorage.setItem('userdata', JSON.stringify(payload.userdata))
    },
    userDataList(state, payload) {
      state.userDataList = payload
    },
    mergeData(state, payload) {
      state.mergeData = payload
    },
  },

  /* dispatch */
  actions: {
  },


  getters: {
  },


  modules: {
  }
})
